{% load wenlincms_tags comment_tags wlcore_tags %}

{% block main %}
    {% pagination_comment wlcomments_for_thread %}

    {% for comment in wlcomments_for_thread %}
        {% if not comment.is_removed %}
            <div id="comment-{{ comment.id }}" style="margin-bottom: 10px;padding: 0;"
                 class="comment media{% if comment.by_author %} comment-author{% endif %}">

                <ul class="am-comments-list am-comments-list-flip">
                    <li class="am-comment">
                        <a>
                            {% spaceless %}
                                {% if comment.user.u_profile.avatar %}
                                    <img src="{{ MEDIA_URL }}{% thumbnail comment.user.u_profile.avatar 52 52 %}"
                                         class="am-comment-avatar" width="48">
                                {% else %}
                                    <img src="{{ STATIC_URL }}" class="am-comment-avatar" width="48">
                                {% endif %}
                            {% endspaceless %}
                        </a>

                        <div class="media-body am-comment-main" style="margin-right:10px;">
                            <header class="media-heading am-comment-hd">
                                <div class="am-comment-meta">
                                    <a href="{% if comment.user.u_profile %}/uc/usr/{{ comment.user.u_profile.slug }}{% endif %}"
                                       target="_blank" title="查看他的主页" class="am-comment-author aut_distance">
                                        {% spaceless %}
                                            {% if comment.user.u_profile %}
                                                {{ comment.user.u_profile.title }}
                                                {% if comment.user.u_profile.audit_status == 1 %}
                                                    <img src="{{ STATIC_URL }}wltheme/img/v.gif" class="vimg"
                                                         alt="数宇科技认证用户"
                                                         width="12px" height="12px"/>
                                                {% endif %}
                                                &nbsp;{{ comment.user.u_profile.unit_title }}
                                            {% else %}
                                                {{ comment.user.username }}
                                            {% endif %}
                                        {% endspaceless %}
                                    </a>
                                </div>
                            </header>
                            <div class="am-comment-bd change_line">
                                <p>{{ comment.comment|richtext_filters|safe }}</p>
                                {% if comment.replied_to_id %}
                                    <blockquote>{{ comment.replied_to_id|show_parent_comment|striptags|truncatechars:40|safe }}</blockquote>
                                {% endif %}
                            </div>
                            <footer class="am-comment-footer">
                                <div class="am-comment-actions" id="small_actions">
                                    <time class="timespan">{{ comment.submit_date|date:"Y-m-j H:i" }}</time>
                                    <a href="#reply-{{ comment.id }}" class="reply" id="reply">
                                        <i class="am-icon-reply"></i> 回复</a>
                                    <a href="#reply-{{ comment.id }}" class="like">
                                        <span class="comment-ding-link" id="support-{{ comment.id }}">支持
                                            <em style="font-style: normal;">({{ comment.support_count }})</em></span></a>
                                </div>
                                <form class="comment-reply-form" method="post" id="reply-{{ comment.id }}"
                                      action="{{ comment_url }}#reply-{{ comment.id }}" style="display: none;">
                                    {% if replied_to == comment.id %}
                                        {% fields_for posted_comment_form %}
                                    {% else %}
                                        {% fields_for unposted_comment_form %}
                                    {% endif %}
                                    <input type="hidden" name="replied_to" value="{{ comment.id }}">

                                    <div class="form-actions">
                                        <button type="reset" class="am-btn am-btn-secondary am-btn-xs cancel_comment">取消
                                        </button>
                                        &nbsp;
                                        <button type="submit" class="am-btn am-btn-secondary am-btn-xs reply_comment">
                                            <span class="am-icon-comments-o"></span> 回复
                                        </button>
                                        <span style="float: left;color: #999;margin-top:5px">请勿发表含有广告性质和联系方式的内容</span>
                                    </div>
                                </form>
                            </footer>
                        </div>
                    </li>
                </ul>
            </div>
        {% endif %}
    {% endfor %}

    {#超过输入字符限制时的提示#}
    <div class="am-modal am-modal-alert" tabindex="-1" id="wl-alert1">
        <div class="am-modal-dialog">
            <div class="am-modal-bd">评论内容太少或超过 500 字</div>
            <div class="am-modal-footer">
                <span class="am-modal-btn">确定</span>
            </div>
        </div>
    </div>
{% endblock %}

{% block scripts %}{% endblock %}
